<template>
  <div class="share">
  	<img src="~assets/images/fenxiang.png" @click.stop.prevent="share">
  </div>
</template>

<script>
  import RemoteDAO from 'common/RemoteDAO'
  import sessionDAO from 'common/sessionDAO'
  export default {
    data () {
      return {
        userCode: sessionDAO.getUserCode() || '',
        title: '股林风云再起，江湖高手对决！',
        content: '各大门派齐聚股林大会，多重豪礼花落谁家？诚邀阁下一展身手！',
        icon: 'https://dl.app.gtja.com/web/gulindahui/share/gulinshare.jpg',
        linkurl: ''
      }
    },
    mounted () {
      this.init()
    },
    methods: {
      init () {
        this.linkurl = 'http://dl.app.gtja.com/nrng/newShares/gldh-game-award.html?source=squarePage&title=' + this.title + '&content=' + this.content + '&userCode=' + this.userCode
        document.getElementsByName('yyzsharetitle')[0].setAttribute('content', this.title)
        document.getElementsByName('yyzsharedescription')[0].setAttribute('content', this.content)
        document.getElementsByName('yyzshareimg')[0].setAttribute('content', this.icon)
        // document.getElementsByName('yyzshareurl')[0].setAttribute('content', this.linkurl)
      },
      share () {
        this.maidian('23014')
        RemoteDAO.sendShareData().then(response => {
          let args = {
            title: this.title,
            content: this.content,
            icon: this.icon,
            moments: 'title',
            linkurl: this.linkurl
          }
          RemoteDAO.share(args)
        })
      },
      maidian (tdId, kv) {
        kv = kv || {}
        let TDAPP = window.TDAPP
        TDAPP.onEvent(tdId, '', kv)
        TDAPP.send()
      }
    }
  }
</script>
